#include <stdio.h>
#include <string.h>
#include "libprinter.h"

extern const unsigned char gImage_man[294];


int main(int argc,char *argv[])
{	
	char read_data[1024]; 
    char cut_data[10]={ 0x1D, 0x56, 0x00};
	int ret;
	char *str;
	char *serialNum;
	int iRet;
	unsigned char n = 0;
	printf("open printer!\n");
	openPrinter(argv[1]);
	//初始化打印机
	resetPrinter();	
	setPriterModeEncode(1);//GBK232模式
	setPrinterModeChinese();//打印中文模式
	
	setPrinterCharSizebig();
char *taiRun = "泰润米花网络";
writePrinter(taiRun,strlen(taiRun));
//confirmPrint();
newLine();
setPrinterCharSize(2, 2);//设置打印的尺寸
writePrinter(taiRun,strlen(taiRun));
newLine();
cutPaper();
	/*
	//打开小票信息
	fd = open("print_utf8.txt",O_RDONLY);
	if (fd < 0)
	{ 
	    perror("open"); 
	    exit(1); 
	}	
	
	while((ret = read(fd,read_data, 2048) )> 0)
	{
		writePrinter(read_data, ret);
		 
          //读流水号进行切割，用于打条形码  
          if( strstr(read_data,"流水号") != NULL)
          {
          	 str =  strdup(read_data);
          	 strsep(&str,":");
          	 strsep(&str,":");
       		 serialNum = strsep(&str," ");
     		
          }             	 	
	}
	
	print_bar(serialNum);//打印条形码
	writePrinter(cut_data, 4); //切割纸条
*/
 	getPrinterState();
	sendState();
	
	
	closePrinter();
	printf("printfer ok!\n");
	return 0;
}
